package model;

import java.util.ArrayList;


import exception.DrawException;

public class CardStack extends CardContainer
{
	public Card drawCard() throws DrawException
	{
		try
		{
			return cards.remove(cards.size() - 1);
		}
		catch (ArrayIndexOutOfBoundsException e)
		{
			throw new DrawException();
		}
	}

	public ArrayList<Card> drawCards(int amount) throws DrawException
	{
		try
		{
			ArrayList<Card> list = new ArrayList<Card>(cards.subList(cards.size() - amount, cards.size()));
			
			cards.removeAll(list);
			
			return list;
		}
		catch (ArrayIndexOutOfBoundsException e)
		{
			throw new DrawException();
		}
	}
}
